package com.lkd.controller;

import com.lkd.result.Result;
import com.lkd.utils.OssTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@Slf4j
public class FileController {

    @Autowired
    private OssTemplate ossTemplate;

    @PostMapping("/api/vm-service/sku/fileUpload")
    public Result uploadFile(MultipartFile fileName) throws IOException {
        String filePath = ossTemplate.upload(fileName.getOriginalFilename(),fileName.getInputStream());
        log.info("文件上传成功，访问地址是：{}",filePath);
        return Result.success(filePath);
    }
}
